package fr.cephb.joperon.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.CheckBox;

public class GWTUtils
	{
	public static String getValue(CheckBox cb)
		{
		Element e=DOMUtils.findDescendantdByName(cb.getElement(),"input");
		if(e==null) return null;
		return e.getAttribute("value");
		}
	
	public static void setValue(CheckBox cb,String value)
		{
		Element e=DOMUtils.findDescendantdByName(cb.getElement(),"input");
		if(e==null) return;
		e.setAttribute("value",value==null?"":value);
		}
	
	static void log(String str)
		{
		log_(str);
		}
	
	static void log(Throwable err)
		{
		GWT.log("error "+err.getMessage(), err);
		log_(err.getMessage());
		}
	
	/** firefox must be started using -console */
	private static native void log_(String str)
		 /*-{
		     if(!dump) return;
		     if(str==null) str="null";
		  	 dump("[LOG] "+ str+"\n\n");
		}-*/;
		
	
	}
